Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 528 Bytes

5.3.3 - swoole_timer_clear.md

File metadata and controls

24 lines (18 loc) · 528 Bytes

swoole_timer_clear

使用定时器ID来删除定时器。

bool swoole_timer_clear(int $timer_id)
  • $timer_id,定时器ID,调用swoole_timer_tickswoole_timer_after后会返回一个整数的ID
  • swoole_timer_clear不能用于清除其他进程的定时器,只作用于当前进程

使用示例

$timer = swoole_timer_after(1000, function(){
    echo "timeout\n";
});

var_dump(swoole_timer_clear($timer));
var_dump($timer);

// 输出:bool(true) int(1)
// 不输出:timeout